StringScanner.ReplaceString Function

Syntax

Result_Flag as L = ReplaceString as l(search as c,replace as c)

Arguments

Result_Flag

True indicates that a replacement was made.

search

The text to find in the buffer.

replace

The replacement text.

Description

Search for text after current offset, and replace it if found.

Discussion

The <StringScanner>.ReplaceString() function replaces the first instance of the Search_Text with Replace_Text. The offset is positioned immediately after Replace_Text.

Example

dim scanner as P
dim txt as C
txt = <<%text%
This is wonderful text
written by a great writer
%text%
scanner = stringscanner.create(txt)
? scanner.replacestring("wonderful","magnificent")
= .T.
? scanner.GetToOffset()
= "This is magnificent"
? scanner.GetRemainder()
=prose written
by a technical writer of note.

See Also